﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using QLKetNoi;
using System.Data.Linq;

namespace QLPhanQuyen.DAO
{
    public class ChucNangDAO
    {
        QLDNDataContext db = new QLDNDataContext();
        Table<CHUCNANG> chucNangs;

        public List<string> DSTenChucNangTheoNhom(string maNhom)
        {
            chucNangs = db.GetTable<CHUCNANG>();

            var query = (from cn in chucNangs
                         where cn.MaNhomChucNang == maNhom
                         select cn.TenChucNang).ToList();
            return query;
        }

        public string LayMaTheoTen(string tenChucNang)
        {
            chucNangs = db.GetTable<CHUCNANG>();

            var query = (from cn in chucNangs
                         where cn.TenChucNang == tenChucNang
                         select cn.MaChucNang).FirstOrDefault();
            return query;
        }
    }
}
